/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Main2.java
 *
 * Created on Dec 29, 2010, 10:21:13 AM
 */

package GUI;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.StringTokenizer;
/**
 *
 * @author Toshiba Satellite
 */
public class Main extends javax.swing.JFrame {

    /** Creates new form Main2 */


    Report_Details re = new Report_Details(this, false);
    DBConnection cd = new DBConnection(this, false);
    Connection con = null;
    

    public Main() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        //testConnection();
       
        re.show();
        initComponents();


    }

//    public void testConnection()
//    {
//        try {
//            File f = new File("config.txt");
//            if(f.exists())
//            {
//            BufferedReader br = new BufferedReader(new FileReader(f));
//            String line = br.readLine();
//            StringTokenizer strToken = new StringTokenizer(line, ",");
//
//            String serverName= strToken.nextToken();
//            String port = strToken.nextToken();
//            String userName = strToken.nextToken();
//            String password = strToken.nextToken();
//            String databaseName = strToken.nextToken();
//
//            //System.out.print(databaseName+","+userName+","+password+","+serverName+","+serverName+","+port);
//            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//            String str = "jdbc:sqlserver://"+serverName+":"+port
//                    +";databaseName="+databaseName+";user="+userName+";password="+password;
//
//            con = DriverManager.getConnection(str,userName,password);
//
//
//            }
//            else
//            {
//                cd.show();
//                BufferedReader br = new BufferedReader(new FileReader(f));
//                String line = br.readLine();
//                StringTokenizer strToken = new StringTokenizer(line, ",");
//
//                String serverName= strToken.nextToken();
//                String port = strToken.nextToken();
//                String userName = strToken.nextToken();
//                String password = strToken.nextToken();
//                String databaseName = strToken.nextToken();
//
//                System.out.print(databaseName+","+userName+","+password+","+serverName+","+serverName+","+port);
//                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//                String str = "jdbc:sqlserver://"+serverName+":"+port
//                        +";databaseName="+databaseName+";user="+userName+";password="+password;
//
//                con = DriverManager.getConnection(str,userName,password);
//            }
//
//
//
//
//        } catch (Exception e) {
////            e.printStackTrace();
//            cd.show();
//        }
//
//    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Jpanel_background = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem18 = new javax.swing.JMenuItem();
        jMenuItem19 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Marvel Consultancies Ltd");

        javax.swing.GroupLayout Jpanel_backgroundLayout = new javax.swing.GroupLayout(Jpanel_background);
        Jpanel_background.setLayout(Jpanel_backgroundLayout);
        Jpanel_backgroundLayout.setHorizontalGroup(
            Jpanel_backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 986, Short.MAX_VALUE)
        );
        Jpanel_backgroundLayout.setVerticalGroup(
            Jpanel_backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 759, Short.MAX_VALUE)
        );

        Jpanel_background = new DisplayImage();

        getContentPane().add(Jpanel_background, java.awt.BorderLayout.CENTER);

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/file.jpg"))); // NOI18N
        jMenu1.setText("File");

        jMenuItem1.setText("Exit");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/report.jpg"))); // NOI18N
        jMenu4.setText("Report");

        jMenuItem8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/Details.jpg"))); // NOI18N
        jMenuItem8.setText("Details");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem8);

        jMenuBar1.add(jMenu4);

        jMenu3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/manager-icon.gif"))); // NOI18N
        jMenu3.setText("Management");
        jMenu3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu3ActionPerformed(evt);
            }
        });

        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/company.jpg"))); // NOI18N
        jMenuItem2.setText("Company ");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem2);

        jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/job seeker.jpg"))); // NOI18N
        jMenuItem3.setText("Job seeker");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem3);

        jMenuItem4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/interview.jpg"))); // NOI18N
        jMenuItem4.setText("Interview");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem4);

        jMenuItem5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/classification.jpg"))); // NOI18N
        jMenuItem5.setText("Classification");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem5);

        jMenuItem6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/recruitment.jpg"))); // NOI18N
        jMenuItem6.setText("Vacancies");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem6);

        jMenuItem7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/money.jpg"))); // NOI18N
        jMenuItem7.setText("Payment");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem7);

        jMenuBar1.add(jMenu3);

        jMenu5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/setting.jpg"))); // NOI18N
        jMenu5.setText("Setting");
        jMenu5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu5ActionPerformed(evt);
            }
        });

        jMenuItem9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/database_icon.gif"))); // NOI18N
        jMenuItem9.setText("Connect to Database");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem9);

        jMenuBar1.add(jMenu5);

        jMenu2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Icon/help2.png"))); // NOI18N
        jMenu2.setText("Help");

        jMenuItem18.setText("About us");
        jMenuItem18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem18ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem18);

        jMenuItem19.setText("How to use this software?");
        jMenu2.add(jMenuItem19);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        try {
           Company com = new Company(this, false);
           com.show();

        } catch (Exception e) {
            e.printStackTrace();
        }


    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        JobSeeker job = new JobSeeker(this, false);
        job.show();

    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
        Interview i = new Interview(this, false);
        i.show();

    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        // TODO add your handling code here:
        Classification cf = new Classification(this, false);
        cf.show();

    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        // TODO add your handling code here:
        Vacancies v = new Vacancies(this, false);
        v.show();

    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        System.exit(0);


    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenu3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu3ActionPerformed
        // TODO add your handling code here:
        

    }//GEN-LAST:event_jMenu3ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        // TODO add your handling code here:
        Payment p = new Payment(this, false);
        p.show();
        
        
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        // TODO add your handling code here:
        
        re.show();


    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenu5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu5ActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_jMenu5ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        // TODO add your handling code here:
        cd.show();

    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem18ActionPerformed
        // TODO add your handling code here:
        try {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.google.com");
            } catch (Exception e) {
                e.printStackTrace();
            }
    }//GEN-LAST:event_jMenuItem18ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel Jpanel_background;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem18;
    private javax.swing.JMenuItem jMenuItem19;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    // End of variables declaration//GEN-END:variables

}

class DisplayImage extends JPanel
{
    Image castle;
    Dimension size;

    public DisplayImage()
    {
        size = new Dimension();

        ImageIcon picIcon = new ImageIcon(getClass().getResource("/Image/background4.jpg"));
        castle = picIcon.getImage();

        size.width = castle.getWidth(null);
        size.height = castle.getHeight(null);
        setPreferredSize(size);
        setBackground(new java.awt.Color(153,204,255));

    }

    @Override
    public void paint(Graphics g)
    {
        Graphics2D g2d = (Graphics2D)g;

        g2d.drawImage(castle,0, 0, null);
    }


}


